package com.xing.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xing.entity.SysMenuEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysMenuDao extends BaseMapper<SysMenuEntity> {

    @Select("select r.url\n" +
            "        from sys_user_role ur\n" +
            "                 left join sys_role ro on ro.id = ur.role_id\n" +
            "                 left join sys_role_resource rr on rr.role_id = ur.role_id\n" +
            "                 left join sys_resource r on r.id = rr.resource_id\n" +
            "        where ur.user_id = #{userId}\n" +
            "          and ro.del_flag = 0\n" +
            "          and r.del_flag = 0;")
    List<String> selectPermsByUserId(@Param("userId") Long userId);

}
